import Vue from 'vue'
import Vuex from 'vuex'
import someMudule from './store/user'

Vue.use(Vuex)

export default new Vuex.Store({
  strict: true,
  modules: {
    someMudule
  },
  state: {
    dapeng: ''
  },
  mutations: {
    putDapengMutation (state, info) {
      state.dapeng = info
    }
  },
  actions: {
    async queryDapengAction ({ commit }) {
      let data = await fetch('http://test.m.pantaojiaoyu.com/api/course/category')
      let resData = await data.json()
      // fetch('http://test.m.pantaojiaoyu.com/api/course/category').then(res => {
      //   return res.json()
      // }).then(res => {
      //   commit('putDapengMutation', res)
      // })
      commit('putDapengMutation', resData)
    }
  },
  getters: {
    dapengGetters: state => state.dapeng
  }
})
